from selenium import webdriver
from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.support import expected_conditions as EC
from selenium.webdriver.common.by import By

options = webdriver.ChromeOptions()
options.add_argument("--proxy-server=http://171.39.42.45:8123")

driver_path = r"D:\chromedriver\chromedriver.exe"
req_url = 'https://www.douban.com'
driver = webdriver.Chrome(executable_path=driver_path, chrome_options=options)
driver.get(req_url)

# 隐式等待
# driver.implicitly_wait(10)
# driver.find_element_by_id('ssssssssss')

# 显示等待
# element = WebDriverWait(driver, 5).until(
#   EC.presence_of_element_located(By.ID, 'fasdfsdf')
# )
# print(element)


driver.execute_script("window.open('https://www.baidu.com')")
driver.switch_to_window(driver.window_handles[1])

print(driver.current_url)

# print(driver.page_source) 是根据driver.current_url决定的
# 